﻿using System;
//using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;

namespace Scheduler.Presentation_Layer
{
    /// <summary>
    /// Contains Global variables for access from various forms
    /// </summary>
    /**Class GlobalVariables
     * @author Sara Tuohy
     * @version 1.0
     * Course : ITEC 4860, Spring 2012
     * Written: March, 2012
     * Stores values to be shared between classes
     * Purpose: to limit need for accessing DB repeatedly.  Data is read and stored
     * here (selectively depending on account type).  Then the DB is only accessed again
     * if changes are made or the user requests historical data.
     */
    public static class GlobalVariables
    {
        /// <summary>
        /// Contains Global variables for access from various forms
        /// Stores OperationDays to avoid repeated accessin DB for
        /// unmodified data
        /// </summary>
        static OperationDay[] globalOperationWeek;

        /// <summary>
        /// Getter/Setter for GlobalOperationWeek
        /// </summary>
        public static OperationDay[] GlobalOperationWeek
        {
            get
            {
                return globalOperationWeek;
            }
            set
            {
                globalOperationWeek = value;
            }
        }

        /// <summary>
        /// Contains Global variables for access from various forms
        /// Bool to verify validity of HoursOfOperation list before retrieving
        /// Note: "True" signifies the following: the operationWeek is current, 
        /// the MaximumWeeklyPayroll is current, and EmployeesPerTimeSlot is current.
        /// </summary>
        static bool globalHoursOfOperationSet = false;

        /// <summary>
        /// Getter/Setter for GlobalHoursOfOperationSet boolean
        /// </summary>
        public static bool GlobalHoursOfOperationSet
        {
            get
            {
                return globalHoursOfOperationSet;
            }
            set
            {
                globalHoursOfOperationSet = value;
            }
        }

        /// <summary>
        /// Contains the ID of the user currently logged in
        /// User ID is used to retrieve data on the current user
        /// Set at Login
        /// </summary>
        static string globalLoggedInUser;

        /// <summary>
        /// Getter/Setter for GlobalLoggedInUser
        /// </summary>
        public static string GlobalLoggedInUser
        {
            get
            {
                return globalLoggedInUser;
            }
            set
            {
                globalLoggedInUser = value;
            }
        }

        /// <summary>
        /// Contains the Company ID (data table access key)
        /// Set at Login
        /// </summary>
        static string globalCompanyID;

        /// <summary>
        /// Getter/Setter for GlobalCompanyID
        /// </summary>
        public static string GlobalCompanyID
        {
            get
            {
                return globalCompanyID;
            }
            set
            {
                globalCompanyID = value;
            }
        }

        /// <summary>
        /// Contains Seven Days of Staff Required, 
        /// Seven days of 48 entries of 0-9999 employees needed.
        /// </summary>
        static ArrayList globalWeeklyStaffNeededEachTimeIncrement;

        /// <summary>
        /// Getter/Setter for GlobalWeeklyStaffNeededEachTimeIncrement
        /// </summary>
        public static ArrayList GlobalWeeklyStaffNeededEachTimeIncrement
        {
            get
            {
                return globalWeeklyStaffNeededEachTimeIncrement;
            }
            set
            {
                globalWeeklyStaffNeededEachTimeIncrement = value;
            }
        }

        /// <summary>
        /// Contains an array of Business_Logic_Layer.Employee[]
        /// Used for Employee Listing
        /// Note: contains all employes regardless of status (Active or Not, Locked or Not)
        /// Does not contain managers.  Use GlobalEmployeeListCompiled (bool) to determine if
        /// the list has been compiled (otherwise will return a null value).
        /// NOTE: Accepts and returns type Business_Logic_Layer.Employee[]
        /// </summary>
        static Array globalEmployeeList;

        /// <summary>
        /// Getter/Setter for GlobalEmployeeList
        /// </summary>
        public static Array GlobalEmployeeList
        {
            get
            {
                return globalEmployeeList;
            }
            set
            {
                globalEmployeeList = value;
            }
        }

        /// <summary>
        /// Contains Global variables for access from various forms
        /// Bool to verify validity of EmployeeList before retrieving
        /// </summary>
        static bool globalEmployeeListCompiled = false;

        /// <summary>
        /// Getter/Setter for GlobalEmployeeListCompiled boolean
        /// </summary>
        public static bool GlobalEmployeeListCompiled
        {
            get
            {
                return globalEmployeeListCompiled;
            }
            set
            {
                globalEmployeeListCompiled = value;
            }
        }

        /// <summary>
        /// Contains the Company Maximum Weekly Payroll
        /// </summary>
        static decimal globalCompanyMaxWeeklyPayroll;

        /// <summary>
        /// Getter/Setter for Company Maximum Weekly Payroll
        /// </summary>
        public static decimal GlobalCompanyMaxWeeklyPayroll
        {
            get
            {
                return globalCompanyMaxWeeklyPayroll;
            }
            set
            {
                globalCompanyMaxWeeklyPayroll = value;
            }
        }

        /// <summary>
        /// Current DateTime in a comparable format (string)
        /// To ensure uniformity in comparisons
        /// </summary>
        static string globalCurrentDateTime;

        /// <summary>
        /// Getter for globalCurrentDateTime
        /// </summary>
        public static string GlobalCurrentDateTime
        {
            get
            {
                //return CurrentDateTime in string yyyyMMddHHmmss format
                string globalCurrentDateTime = formatNowString();
                return globalCurrentDateTime;
            }
        }

        /// <summary>
        /// Formatter for string for globalCurrentDateTime
        /// </summary>
        private static string formatNowString()
        {
            string now = DateTime.Now.ToString("yyyyMMddHHmmss");
            //now = now.Substring(0, 12);
            return now;
        }

        /// <summary>
        /// Contains Global variables for access from various forms
        /// String[] of week days in the format the data base expects - Read only - "Sunday", ..., "Saturday"
        /// </summary>
        static string[] globalWeekDays = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };

        /// <summary>
        /// Getter for GlobalWeekDays - "Sunday", ..., "Saturday"
        /// </summary>
        public static string[] GlobalWeekDays
        {
            get
            {
                return globalWeekDays;
            }
        }


        /// <summary>
        /// Contains Global variables for access from various forms
        /// String[] of all time slots in the format the data base expects - Read only - "00:00", ..., "23:30"
        /// </summary>
        public static string[] globalAllTimeSlots = { " ",  "00:00", "00:30", "01:00", "01:30", "02:00", "02:30", 
                                                            "03:00", "03:30", "04:00", "04:30", "05:00", "05:30", 
                                                            "06:00", "06:30", "07:00", "07:30", "08:00", "08:30", 
                                                            "09:00", "09:30", "10:00", "10:30", "11:00", "11:30",
                                                            "12:00", "12:30", "13:00", "13:30", "14:00", "14:30",
                                                            "15:00", "15:30", "16:00", "16:30", "17:00", "17:30",
                                                            "18:00", "18:30", "19:00", "19:30", "20:00", "20:30", 
                                                            "21:00", "21:30", "22:00", "22:30", "23:00", "23:30"};
        /// <summary>
        /// Getter for GlobalAllTimeSlots - "00:00", ..., "23:30"
        /// </summary>
        public static string[] GlobalAllTimeSlots
        {
            get
            {
                return globalAllTimeSlots;
            }
        }

    }
}
